home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / misc / ImageFXDevKit.lha / sdev / sas / examples / drawmodes / trail.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-26  |  3.6 KB  |  138 lines

  1. /*
  2.  * A Drawing Mode for ImageFX 1.5
  3.  *
  4.  */
  5.  
  6. #include <exec/types.h>
  7. #include <scan/modall.h>
  8.  
  9. #define MAX(a,b)     ((a) > (b) ? (a) : (b))
  10.  
  11. /**********************************************************************\
  12.  
  13.                                 Library Vectors
  14.  
  15. \**********************************************************************/
  16.  
  17. short mix = 255;
  18.  
  19. int __asm DM_PutInit (void)
  20. {
  21.    return(1);
  22. }
  23.  
  24. void __asm DM_PutCleanup (void)
  25. {
  26. }
  27.  
  28. void __asm DM_PutColor (register __a0 short *destr,
  29.                         register __a1 short *destg,
  30.                         register __a2 short *destb,
  31.                         register __d0 LONG oldr,
  32.                         register __d1 LONG oldg,
  33.                         register __d2 LONG oldb,
  34.                         register __d3 LONG newr,
  35.                         register __d4 LONG newg,
  36.                         register __d5 LONG newb,
  37.                         register __d6 LONG x,
  38.                         register __d7 LONG y)
  39. {
  40.    *destr = mixer(newr, oldr, mix);
  41.    *destg = mixer(newg, oldg, mix);
  42.    *destb = mixer(newb, oldb, mix);
  43. }
  44.  
  45. void __asm DM_PutGrey  (register __a0 short *destg,
  46.                         register __d0 LONG oldg,
  47.                         register __d1 LONG newg,
  48.                         register __d6 LONG x,
  49.                         register __d7 LONG y)
  50. {
  51.    *destg = mixer(newg, oldg, mix);
  52. }
  53.  
  54. /*
  55.  * You cannot rely on this being called after DM_PutInit(), or
  56.  * vice versa.
  57.  *
  58.  * x, y, and z will be -1 if the drawing tool in question is
  59.  * not a curve (eg. a box or something).
  60.  *
  61.  */
  62. void __asm DM_NewPoint (register __d0 int n,
  63.                         register __d1 int total,
  64.                         register __d2 int x,
  65.                         register __d3 int y,
  66.                         register __d4 int z)
  67. {
  68.    /* This is called at every point along a user-drawn curve. */
  69.  
  70.    if (x >= 0) {
  71.       mix = n * 255 / total;
  72.    }
  73.    else {
  74.       mix = 255;
  75.    }
  76. }
  77.  
  78. /**********************************************************************\
  79.  
  80.                          Library Initialization Stuff
  81.  
  82. \**********************************************************************/
  83.  
  84. /*
  85.  * This is the table of all the functions that can be called in this
  86.  * module.  The first four (Open, Close, Expunge, and Null) are reserved
  87.  * for system use and MUST be specified in the order shown.  The actual
  88.  * functions are in the standard module startup code.
  89.  */
  90. ULONG FuncTable[] = {
  91.    /* These four MUST be present in this order */
  92.    (ULONG) LibOpen,
  93.    (ULONG) LibClose,
  94.    (ULONG) LibExpunge,
  95.    (ULONG) LibNull,
  96.  
  97.    /* Specific to the module */
  98.    (ULONG) DM_PutInit,
  99.    (ULONG) DM_PutCleanup,
  100.    (ULONG) DM_PutColor,
  101.    (ULONG) DM_PutGrey,
  102.    (ULONG) DM_NewPoint,
  103.  
  104.    /* End with -1L */
  105.    (ULONG) -1L
  106. };
  107.  
  108. /*
  109.  * These are used by the standard module startup code.
  110.  * LibraryName is the name of the library, and LibraryID is a short
  111.  * description of the library.  Both of these are largely irrelavent,
  112.  * but they are included just for completeness.
  113.  */
  114. UBYTE LibraryID[]    = "$VER: Trail Drawing Mode 1.04.05 (12.6.93)";
  115. UBYTE LibraryType    = NT_DRAWMODE;
  116.  
  117. /*
  118.  * This is called by the standard module startup code when Image Scan
  119.  * first opens the module.  Here we should fill in the NumGads,
  120.  * NewGad, Language, and LangCount fields of the provided ModuleBase
  121.  * structure if necessary.
  122.  */
  123. long  __asm UserOpen (register __a6 struct ModuleBase *modbase)
  124. {
  125.    return(TRUE);
  126. }
  127.  
  128. /*
  129.  * This is called by the standard module startup code when Image Scan
  130.  * closes the module.  It should cleanup anything allocated or obtained
  131.  * in the UserOpen() function.
  132.  */
  133. long  __asm UserClose (register __a6 struct ModuleBase *modbase)
  134. {
  135.    return(TRUE);
  136. }
  137.  
  138.